$(function() {
		
	// 定义列
	var columns = [
		{
				field : 'no',
				title : '序号',
				align : 'left',
				formatter : function(value, row, index) {
					return index + 1;
				}
		},
		{
				field : 'orderCode',
				title : '订单编号',
				align : 'center'
		},
		{
				field : 'tradeNo',
				title : '交易流水号',
				align : 'center'
		},
		{
				field : 'buyerPayAmount',
				title : '买家付款金额',
				align : 'center'
		},
		{
				field : 'receiptAmount',
				title : '收款金额',
				align : 'center'
		},
		{
				field : 'notifyType',
				title : '通知类型 ',
				align : 'center'
		},
		{
				field : 'notifyTime',
				title : '通知时间',
				align : 'center'
		},
		{
				field : 'tradeStatus',
				title : '交易状态',
				align : 'center'
		},
		{
				field : 'rsaCheckResult',
				title : '验签结果',
				align : 'center'
		},
		{
				field : 'rsaCheckTime',
				title : '验签时间',
				align : 'center'
		},
		{
				field : 'rsaBizCheckReason',
				title : '验签失败原因',
				align : 'center'
		},
		{	
			field : '#',
			title : '操作',
			align : 'center',
			formatter : function(value, row, index) {
				if (row.status == "0") {
					return "<a href='javaScript:void(0);'onclick='updateStatus("
								+ row.id
								+ ","
								+ row.status
								+ ")'>启用</a>"
								+ "<a href='javaScript:void(0);'onclick='toEdit("
								+ row.id + ")'>编辑</a>";
				} else if (row.status == "1") {
					return "<a href='javaScript:void(0);'onclick='updateStatus("
								+ row.id
								+ ","
								+ row.status
								+ ")'>停用</a>"
								+ "<a href='javaScript:void(0);'onclick='toEdit("
								+ row.id + ")'>编辑</a>";
				}
			}
		}, ];
			
			
	// 定义查询回调函数（查询参数在此设置）
	var queryParams = function(params) {
	
		var id =  $("#id").val()
		var orderCode =  $("#orderCode").val()
		var tradeNo =  $("#tradeNo").val()
		var buyerPayAmount =  $("#buyerPayAmount").val()
		var receiptAmount =  $("#receiptAmount").val()
		var notifyType =  $("#notifyType").val()
		var notifyTime =  $("#notifyTime").val()
		var tradeStatus =  $("#tradeStatus").val()
		var notifyContent =  $("#notifyContent").val()
		var rsaCheckResult =  $("#rsaCheckResult").val()
		var rsaCheckTime =  $("#rsaCheckTime").val()
		var rsaBizCheckReason =  $("#rsaBizCheckReason").val()
		
		return {
			rows : params.limit, // 页面大小
			page : params.pageNumber, // 页码
			id : id,
			orderCode : orderCode,
			tradeNo : tradeNo,
			buyerPayAmount : buyerPayAmount,
			receiptAmount : receiptAmount,
			notifyType : notifyType,
			notifyTime : notifyTime,
			tradeStatus : tradeStatus,
			notifyContent : notifyContent,
			rsaCheckResult : rsaCheckResult,
			rsaCheckTime : rsaCheckTime,
			rsaBizCheckReason : rsaBizCheckReason
		};
	};
	
	var url = rootPath + "/orderAlipayNotifyLog/listOrderAlipayNotifyLogPage"; // 请求json数据的服务器地址
	sys.initTable('orderAlipayNotifyLogTable', {
		url : url,
		queryParams : queryParams,
		columns : columns,
		striped : true,
		clickToSelect : true
	});

	// 查询
	$('#btnQuery').on('click', function() {
		sys.reloadTable('orderAlipayNotifyLogTable');
	});
	
	// 清空
	$('#btnClear').on('click', function() {
		$("#id").val("");
		$("#orderCode").val("");
		$("#tradeNo").val("");
		$("#buyerPayAmount").val("");
		$("#receiptAmount").val("");
		$("#notifyType").val("");
		$("#notifyTime").val("");
		$("#tradeStatus").val("");
		$("#notifyContent").val("");
		$("#rsaCheckResult").val("");
		$("#rsaCheckTime").val("");
		$("#rsaBizCheckReason").val("");
	});

	$('#btnAdd').on('click', function() {
		sys.showRemote(rootPath + '/orderAlipayNotifyLog/toAddOrderAlipayNotifyLog', function() {
			var key = sys.dialog.getData("key");
			if (key == '1') {
				sys.showSuccess("添加成功！", sys.reloadTable('orderAlipayNotifyLogTable'));
			} else if (key == '0') {
				sys.showErr("添加失败！");
			}
		}, {
			title : '新增订单支付宝支付日志',
			width : 600,
			height : 600
		});

	});

})

// 跳转编辑页面
function toEdit(id) {
	window.location.href = rootPath + "/orderAlipayNotifyLog/toUpdateOrderAlipayNotifyLog?id=" + id;
}